#!/bin/sh
#snackf0boss.sh
# this script extracts the f0-information and requires a filelist "filelist.txt" and the raw-files
# it uses tcl and the snackpackage [libsnack2-alsa on ubuntu]

#@version: 1.0
#@author: Filip Müllers

# the next line restarts using tclsh \
exec tclsh "$0" "$@"

package require snack

snack::sound s

set f [open filelist.txt] 
set list [read $f]
close $f

foreach file $list { 
 s read raw/$file.raw -rate 16000 -format Lin16
 puts "Processing $file.raw..."
 set fd [open f0/[file rootname $file].f0_ascii w] 
 puts $fd [join [s pitch -method esps -framelength 0.005 -windowlength 0.02] \n] 
 close $fd 
}
puts "\n\n Done."

exit
